﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using CSC.FSVTracker.Domain.Abstract;
using CSC.FSVTracker.Domain.Entities;

namespace CSC.FSVTracker.WebUI.Controllers
{
    public class BaseController : Controller
    {
        /// <summary>
        /// User Repository
        /// </summary>
        protected IUserRepository userRepository;

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseController"/> class.
        /// </summary>
        public BaseController()
        {
            this.userRepository = null;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseController"/> class.
        /// </summary>
        /// <param name="repository">The repository.</param>
        public BaseController(IUserRepository repository)
        {
            this.userRepository = repository;
        }

        /// <summary>
        /// Called after the action method is invoked.
        /// </summary>
        /// <param name="filterContext">Information about the current request and action.</param>
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if ((User)Session["User"] == null)
            {
                RedirectToAction("Login", "Account");
            }
        }
    }
}
